---
created:
source_filename: /home/runner/work/mknodes/mknodes/mknodes/pages/mkclasspage/__init__.py
source_function: MkClassPage.__init__
source_line_no: 46
hide:
- toc
icon: material/help
status: new
template: SUMMARY.html
title: MkInstallGuide
---
[:fa-brands-github: Show source on GitHub](https://github.com/phil65/mknodes/blob/main/mknodes/templatenodes/mkinstallguide/__init__.py)
### Node to display an install guide.
=== "Examples"
### Example: **Regular**
!!! jinja "Jinja"
``` {.jinja }
{{ mk.MkInstallGuide() }}
```
!!! python "Python"
``` {.python }
MkInstallGuide()
```
===! "Rendered"
### pip
The latest released version is available at the [Python package index](https://pypi.org/project/mknodes).
```` {.python }
pip install mknodes
````
### pipx
[pipx](https://github.com/pypa/pipx) allows for the global installation of Python applications in isolated environments.
```` {.python }
pipx install mknodes
````
=== "Markdown"
``` {.markdown }
### pip
The latest released version is available at the [Python package index](https://pypi.org/project/mknodes).
```` {.python }
pip install mknodes
````
### pipx
[pipx](https://github.com/pypa/pipx) allows for the global installation of Python applications in isolated environments.
```` {.python }
pipx install mknodes
````
```
=== "Html"
``` {.html }
```
### Example: **Explicit**
!!! jinja "Jinja"
``` {.jinja }
{{ "mkdocs" | MkInstallGuide(package_repos=["pip", "pipx"]) }}
```
!!! python "Python"
``` {.python }
MkInstallGuide('mkdocs', package_repos=['pip', 'pipx'])
```
===! "Rendered"
### pip
The latest released version is available at the [Python package index](https://pypi.org/project/mkdocs).
```` {.python }
pip install mkdocs
````
### pipx
[pipx](https://github.com/pypa/pipx) allows for the global installation of Python applications in isolated environments.
```` {.python }
pipx install mkdocs
````
=== "Markdown"
``` {.markdown }
### pip
The latest released version is available at the [Python package index](https://pypi.org/project/mkdocs).
```` {.python }
pip install mkdocs
````
### pipx
[pipx](https://github.com/pypa/pipx) allows for the global installation of Python applications in isolated environments.
```` {.python }
pipx install mkdocs
````
```
=== "Html"
``` {.html }
pip
The latest released version is available at the Python package index.
pipx
pipx allows for the global installation of Python applications in isolated environments.
```
=== "Repr tree"
```
MkInstallGuide
├── MkHeader('pip', level=3)
├── MkCode('pip install mkdocs')
│ ╰── MkText('pip install mkdocs')
├── MkHeader('pipx', level=3)
╰── MkCode('pipx install mkdocs')
╰── MkText('pipx install mkdocs')
```
=== "DocStrings"
::: mknodes.MkInstallGuide
options:
show_docstring_description: False
=== "Base classes"
| Name | Children | Inherits |
|--- | --- | --- |
| **[MkTemplate](https://phil65.github.io/mknodes/)**
*mknodes.templatenodes.mktemplate*
Node representing a jinja template\. | - [MkCliDoc](https://phil65.github.io/mknodes/)
- [MkMaterialBadge](https://phil65.github.io/mknodes/)
- [MkImageCompare](https://phil65.github.io/mknodes/)
- [MkImageSlideshow](https://phil65.github.io/mknodes/)
- [MkIFrame](https://phil65.github.io/mknodes/)
- [MkCard](https://phil65.github.io/mknodes/)
- [MkInstallGuide](https://phil65.github.io/mknodes/)
- [MkCodeOfConduct](https://phil65.github.io/mknodes/)
- [MkCommitConventions](https://phil65.github.io/mknodes/)
- [MkPullRequestGuidelines](https://phil65.github.io/mknodes/)
- [MkDevEnvSetup](https://phil65.github.io/mknodes/)
- ...
| - [MkContainer](https://phil65.github.io/mknodes/)
|
=== "⋔ Inheritance diagram"
``` mermaid
graph TD
93860743668384["mkinstallguide.MkInstallGuide"]
93860738888176["mktemplate.MkTemplate"]
93860744077920["mkcontainer.MkContainer"]
93860744073616["mknode.MkNode"]
93860744080896["node.Node"]
140589822947552["builtins.object"]
93860738888176 --> 93860743668384
93860744077920 --> 93860738888176
93860744073616 --> 93860744077920
93860744080896 --> 93860744073616
140589822947552 --> 93860744080896
```
=== "NodeFile"
``` {.toml title='/home/runner/work/mknodes/mknodes/mknodes/templatenodes/mkinstallguide/metadata.toml'}
[metadata]
name = "MkInstallGuide"
icon = "mdi:help"
group = "documentation"
virtual_children = true
[examples.regular]
title = "Regular"
jinja = """
{{ mk.MkInstallGuide() }}
"""
[examples.explicit]
title = "Explicit"
jinja = """
{{ "mkdocs" | MkInstallGuide(package_repos=["pip", "pipx"]) }}
"""
[output.markdown]
template = """
{% for method in node.package_repos %}
{{ method.ID | MkHeader(level=node.header_level) }}
{{ method.info_text() }}
{{ method.install_instructions() | MkCode }}
{% endfor %}
"""
# proj = self.associated_distribution
# if method.ID == "pip" and proj and (extras := proj.info.extras):
# extras_str = ",".join(extras)
# text = f"{method.install_instructions()}[{extras_str}]"
# code = mkcode.MkCode(text)
# items.append(code)
```
=== "Code"
``` {.python title='mknodes.templatenodes.mkinstallguide.MkInstallGuide' linenums='13'}
class MkInstallGuide(mktemplate.MkTemplate):
"""Node to display an install guide."""
ICON = "material/help"
VIRTUAL_CHILDREN = True
def __init__(
self,
distribution: str | None = None,
*,
package_repos: list[installmethods.InstallMethodStr] | None = None,
header_level: int = 3,
**kwargs: Any,
):
"""Constructor.
Args:
distribution: name of the distribution to install
package_repos: package repositories the project is available on
header_level: Header level for each section
kwargs: Keyword arguments passed to parent
"""
super().__init__("output/markdown/template", **kwargs)
self._distribution = distribution
self.header_level = header_level
self._package_repos = package_repos
@property
def package_repos(self) -> list[installmethods.InstallMethod]:
if self._package_repos:
return [
installmethods.InstallMethod.by_id(i)(self.distribution)
for i in self._package_repos
]
return self.ctx.metadata.package_repos or []
@property
def distribution(self):
return self._distribution or self.ctx.metadata.distribution_name
@distribution.setter
def distribution(self, value):
self._distribution = value
```